raar.world
Class RAWorld

java.lang.Object
  extended by vectorimage.VectorImage
      extended by raar.world.RAWorld
All Implemented Interfaces:
java.io.Serializable

public class RAWorld
extends VectorImage

The world contains objects to simulate with.

See Also:
Serialized Form

Field Summary
static int AGENT_CROSSING_EDGE
          Setting what should happen if the agent crosses the edge of the map.
static boolean SHOW_SENSOR_SHAPES
          Whether or not to show sensor shapes in the world visual representation.
static int SPEED_SCALAR
          Number of pixels to advance agents if their speed is 1.
static int STOP_LOOP
          Setting: if agent crosses the edge of the map, appear at opposite end.
static int STOP_REMAIN
          Setting: if agent crosses the edge of the map, remain there.
static int STOP_STOP
          Setting: if agent crosses the edge of the map, stop simulation.
 
Constructor Summary
RAWorld(java.lang.String sourceCode, java.awt.Dimension size, java.awt.Color bgColor, java.util.Vector classes, java.util.Vector objects)
          Construct a world with source code, size, colour, classes and objects as specified.
 
Method Summary
 void addAgent(RAAgent agent)
          Add an agent to the world.
 boolean containsAgent(RAAgent agent)
          See whether the world contains this agent.
 boolean containsObject(RAWorldObject object)
          Return whether the world contains the object given.
 RAWorldObject[] createExampleInstance(java.lang.String className)
          Create an example instance of a class.
 double distance(java.awt.geom.Point2D.Double point, RAWorldObject object, java.awt.Shape inRegion)
          Return the distance between point and object, provided that we only look inside inRegion.
 java.util.Vector getAgents()
          Return the agents in this world.
 java.awt.Color getClassColor(java.lang.String className)
          Return the colour of objects of this class.
 java.util.Vector getClassNames()
          Return the names of the object classes present in this world.
 java.util.Vector getFactoryObjectNames()
          Return the objects that can be constructed with factories.
 GVectorObject[] getGVectorObjects(VectorObject vo)
          Return graphical representation(s) for the object given.
 java.awt.Color getObjectColor(java.lang.String objectName)
          Return the colour of object given.
 java.util.Vector getObjects()
          Return the RAWorldObjects present, including agents -- overridden.
 java.lang.String getSourceCode()
          Return the source code.
 boolean isAgentGrippingSomething(RAAgent a)
          Return whether the agent's gripper is currently gripping something.
 void processAgent(RAAgent agent)
          Process the agent, ie. make sure that it moves and acts according to its actors.
 void removeAgent(RAAgent agent)
          Remove an agent from the world.
 void reset()
          Reset the entire world.
 void tryAddObject(java.lang.String className, java.lang.String name, RAAgent agent)
          Let agent try to add an object with name given, of class name given.
 void tryRemoveObject(java.lang.String className, RAAgent agent)
          Let agent try to remove an object with name given, of class name given.
 
Methods inherited from class vectorimage.VectorImage
addObject, findObjectAt, getBackground, getSize, getUsedColors, removeObject, setBackground, setSize
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

SHOW_SENSOR_SHAPES

public static boolean SHOW_SENSOR_SHAPES
Whether or not to show sensor shapes in the world visual representation.


STOP_LOOP

public static final int STOP_LOOP
Setting: if agent crosses the edge of the map, appear at opposite end.

See Also:
Constant Field Values

STOP_REMAIN

public static final int STOP_REMAIN
Setting: if agent crosses the edge of the map, remain there.

See Also:
Constant Field Values

STOP_STOP

public static final int STOP_STOP
Setting: if agent crosses the edge of the map, stop simulation.

See Also:
Constant Field Values

AGENT_CROSSING_EDGE

public static int AGENT_CROSSING_EDGE
Setting what should happen if the agent crosses the edge of the map.


SPEED_SCALAR

public static int SPEED_SCALAR
Number of pixels to advance agents if their speed is 1.

Constructor Detail

RAWorld

public RAWorld(java.lang.String sourceCode,
               java.awt.Dimension size,
               java.awt.Color bgColor,
               java.util.Vector classes,
               java.util.Vector objects)
Construct a world with source code, size, colour, classes and objects as specified. Used by RAWorldReader.

Method Detail

getSourceCode

public java.lang.String getSourceCode()
Return the source code.


getObjects

public java.util.Vector getObjects()
Return the RAWorldObjects present, including agents -- overridden.

Overrides:
getObjects in class VectorImage

getFactoryObjectNames

public java.util.Vector getFactoryObjectNames()
Return the objects that can be constructed with factories.


getClassNames

public java.util.Vector getClassNames()
Return the names of the object classes present in this world.


getClassColor

public java.awt.Color getClassColor(java.lang.String className)
                             throws java.lang.ClassNotFoundException
Return the colour of objects of this class.

Throws:
java.lang.ClassNotFoundException

getObjectColor

public java.awt.Color getObjectColor(java.lang.String objectName)
Return the colour of object given.


containsObject

public boolean containsObject(RAWorldObject object)
Return whether the world contains the object given.


distance

public double distance(java.awt.geom.Point2D.Double point,
                       RAWorldObject object,
                       java.awt.Shape inRegion)
Return the distance between point and object, provided that we only look inside inRegion.


addAgent

public void addAgent(RAAgent agent)
Add an agent to the world.


containsAgent

public boolean containsAgent(RAAgent agent)
See whether the world contains this agent.


removeAgent

public void removeAgent(RAAgent agent)
Remove an agent from the world.


processAgent

public void processAgent(RAAgent agent)
                  throws RAException
Process the agent, ie. make sure that it moves and acts according to its actors.

Throws:
RAException

isAgentGrippingSomething

public boolean isAgentGrippingSomething(RAAgent a)
Return whether the agent's gripper is currently gripping something.


getAgents

public java.util.Vector getAgents()
Return the agents in this world.


createExampleInstance

public RAWorldObject[] createExampleInstance(java.lang.String className)
Create an example instance of a class.


tryAddObject

public void tryAddObject(java.lang.String className,
                         java.lang.String name,
                         RAAgent agent)
Let agent try to add an object with name given, of class name given.


tryRemoveObject

public void tryRemoveObject(java.lang.String className,
                            RAAgent agent)
Let agent try to remove an object with name given, of class name given.


reset

public void reset()
           throws RAException
Reset the entire world.

Throws:
RAException

getGVectorObjects

public GVectorObject[] getGVectorObjects(VectorObject vo)
Return graphical representation(s) for the object given.

Overrides:
getGVectorObjects in class VectorImage